cmake_minimum_required(VERSION 3.13)

project(helloworld.elf)

add_subdirectory(hello-world)

aux_source_directory(. SRC_FILES)

add_executable(${PROJECT_NAME} ${SRC_FILES})

target_link_libraries(${PROJECT_NAME} PRIVATE helloworld)

set_property(DIRECTORY ${CMAKE_BINARY_DIR}
             PROPERTY ADDITIONAL_CLEAN_FILES
                     ${PROJECT_NAME}.tar.gz
                     _CPack_Packages
            )


#use cpack generate xxx.tar.gz
#指定打包后动态库的存储路径
set(CPACK_LIB_INSTALL_DIR "lib/")

install(TARGETS ${PROJECT_NAME}
        DESTINATION .
    )
install(FILES
        ${CMAKE_SOURCE_DIR}/README.md
        DESTINATION .
    )

#install install.sh
install(PROGRAMS
        ${CMAKE_SOURCE_DIR}/install.sh
        DESTINATION .
    )

set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_VENDOR "sdc")
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME})

include(CPack)

